(function() {
	var remote_server_url = "http://121.40.18.23:1518/api/complex/StoreFromMapFactory";
	// var remote_server_url = "http://localhost:1518/api/complex/StoreFromMapFactory";

	Path.on("/__basename__.html", function(_current_location) {
		var queryString = _current_location.query;
		var geotable_id = queryString.get("geotable_id");
		console.log(geotable_id);
		var store_preview_dtd = new $.Deferred();
		$.when(get_store_info(geotable_id, store_preview_dtd)).then(function(store) {
			console.log("store", store);
			var img_len = store.store_imgs.length;
			// 保证图片容器高度
			var _width = $(".preview_img_box").width();
			$(".preview_img_box").height(_width);
			// 轮播
			var $preview_imgs = $(".preview_img_box img");
			$top_preview_img = $preview_imgs[0];
			var _i = 0;
			setInterval(function() {
				$($top_preview_img).stop().animate({
					marginLeft: -_width * (_i % img_len)
				}, 300);
				_i++;
			}, 3000);
		});
	});

	// 获取店铺信息
	function get_store_info(store_id, dtd) {
		$.getJSON(remote_server_url, {
			geotable_id: store_id
		}, function(store_info) {
			store_info.store_imgs = store_info.store_imgs.split(",");
			App.set("$Cache.store_preview.store_info", store_info);
			dtd.resolve(store_info);
		});
		return dtd;
	};

	// 一键导航
	App.set("$Event.store_preview.navigation", function() {
		myConfirm("功能完善中！");
	});
	// 我的收藏
	App.set("$Event.store_preview.mycollections", function() {
		myConfirm("功能完善中！");
	});
}());